MongoDB
安装MongoDB:
$ brew tap mongodb/brew
$ brew install mongodb-community@4.0
参考官网:https://docs.mongodb.com/v4.0/tutorial/install-mongodb-on-os-x/
实际安装路径:/usr/local/Cellar/mongodb-community/4.2.0
bin目录:/usr/local/bin //软链接方式
配置文件:/usr/local/etc/mongod.conf
数据目录:/usr/local/var/mongodb
日志路径:/usr/local/var/log/mongodb/mongo.log
启动MongoDB
$ mongod --config /usr/local/etc/mongod.conf
查看MongoDB日志
$ tail -f /usr/local/var/log/mongodb/mongo.log
卸载MongoDB
$ brew uninstall mongodb-community
Redis
安装Redis:
$ brew install redis
实际安装路径:/usr/local/Cellar/redis/5.0.6
bin目录:/usr/local/bin //软链接方式
配置文件:/usr/local/etc/redis.conf
数据目录:/usr/local/var/db/redis/
日志文件:/usr/local/var/log/redis.log
启动Redis
$ redis-server /usr/local/etc/redis.conf
查看Redis日志
$ tail -f /usr/local/var/log/redis.log
卸载Redis
$ brew uninstall redis
Nginx
安装Nginx:
$ brew install nginx
实际安装路径:/usr/local/Cellar/nginx/1.17.3_1
bin目录:/usr/local/bin //这里使用的是软链接,实际路径在:/usr/local/Cellar/nginx/1.17.3_1/bin
www路径:/usr/local/var/www //静态文件存放路径
配置文件:/usr/local/etc/nginx/nginx.conf
子站配置文件路径:/usr/local/etc/nginx/servers/*.conf //nginx默认会加载这个目录下所有配置文件,路径可以在nginx.conf中修改
日志路径:/usr/local/var/log/nginx/access.log
启动Nginx
$ nginx
后台运行且登录时启动
$ brew services start nginx
查看Nginx日志
$ tail -f /usr/local/var/log/nginx/access.log
卸载Nginx
$ brew uninstall nginx
MySQL
安装MySQL
$ brew install mysql
安装包路径:/usr/local/Cellar/mysql/8.0.18
bin目录:/usr/local/bin //这里使用的是软链接,实际路径在:/usr/local/Cellar/mysql/8.0.18/bin
配置文件目录:/usr/local/etc/my.cnf
数据目录:/usr/local/var/mysql
错误日志路径:/usr/local/var/mysql/tzq.local.err //日志文件名称不同的机器不一样,我这里的是用我的hostname作为前缀命名的
启动MySQL:
$ mysql.server start
后台运行并且登录时启动
$ brew services start mysql
安全起见,最好给数据库设置密码,运行如下命令(强烈建议)
$ mysql_secure_installation
VALIDATE PASSWORD COMPONENT can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD component?Press y|Y for Yes, any other key for No: n
首次进来提示是否使用密码校验组件,由于MySQL密码校验比较严格,加上我是本地使用就不需要太复杂的密码。所以不使用密码校验组件。如果您使用了这个组件,密码设置太简单可能会遇到如下的失败提示:
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : Y
… Failed! Error: Your password does not satisfy the current policy requirements
解决方法1:设置更复杂的密码解决方法2:删除这个校验组件,方法如下
登录数据库
$ mysql -uroot
然后执行如下命令
mysql> uninstall plugin validate_password; //适用于MySQL 8以下版本
或者
mysql> uninstall component ‘file://component_validate_password’; //适用于MySQL 8.0.x
Query OK, 0 rows affected (0.00 sec)再次使用mysql_secure_installation进行设置,记住再次询问是否安装密码校验组件的时候,选择No
查看MySQL日志文件
$ tail -f /usr/local/var/mysql/tzq.local.err
重启MySQL
$ mysql.server restart
停止MySQL
$ mysql.server stop
卸载MySQL
$ brew uninstall mysql